package com.gzdh.dishrecognition.ui.adapter.inputNumber;

import android.content.Context;
import android.graphics.Color;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.gzdh.dishrecognition.R;
import com.gzdh.dishrecognition.entity.BmcmEntity;
import com.gzdh.dishrecognition.ui.adapter.defaultview.FoodsAdapter;

import java.util.List;

public class BmcmAdapter extends RecyclerView.Adapter<BmcmAdapter.MyViewHolder> {


    private LayoutInflater inflater;

    private Context mContext;

    private List<BmcmEntity> bmcmEntityList;

    private TextView nameTv;

    public BmcmAdapter(Context context) {
        inflater = LayoutInflater.from(context);
        mContext = context;
    }

    private View getViews() {
        LinearLayout mainLinear = new LinearLayout(mContext);
        mainLinear.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        mainLinear.setPadding(0, 10, 0, 10);

        nameTv = new TextView(mContext);
        nameTv.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        nameTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
        nameTv.setTextColor(Color.BLACK);
        mainLinear.addView(nameTv);
        return mainLinear;
    }


    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = getViews();
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        nameTv.setText(bmcmEntityList.get(position).getName());
    }

    @Override
    public int getItemCount() {
        return bmcmEntityList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        public MyViewHolder(View itemView) {
            super(itemView);
        }
    }
}
